<?php
class AjaxController extends Controller {

	public function indexAction() {

	}

	public function tengxunAction() {
		session_start();
		header('Content-Type: text/html; charset=utf-8');
 		set_include_path(dirname(dirname(__FILE__)) . '/extensions/tengxun/');
 		require_once 'OpenSDK/Tencent/Weibo.php';
 		require_once 'appkey.php';

		//获取token
		$tengxun_token_model = $this->model('tengxun_token');
		$tokendata = $tengxun_token_model->from('tengxun_token')->where('userid=?', $_SESSION['userid'])->select();	

		//腾讯数据初始化
		$_SESSION['tencent_oauth_token'] = $tokendata[0]['oauth_token'];
		$_SESSION['tencent_oauth_token_secret'] = $tokendata[0]['oauth_token_secret'];
		$_SESSION['tencent_access_token'] = $tokendata[0]['access_token'];

		OpenSDK_Tencent_Weibo::init($appkey, $appsecret);
		OpenSDK_Tencent_Weibo::getAccessToken($_GET['oauth_verifier']);
		
		$homemessage = OpenSDK_Tencent_Weibo::call('statuses/home_timeline');

		$this->set_layout('main2');
		$this->assign('homemessage',$homemessage);
		$this->display();

	}

}